<template>
  <div>
    <div>兑换记录</div>

    <div
      v-for="item in records"
      :key="item.key"
    >
      {{ item.name }} {{ item.exchangeDate | formatTime }}
    </div>
  </div>
</template>

<script>
import { mapState } from 'vuex';
import { v4 as uuidv4 } from 'uuid';
import moment from 'moment';

export default {
  filters: {
    formatTime(v) {
      return moment(v).format('YYYY-MM-DD HH:mm:ss');
    },
  },
  computed: {
    ...mapState({
      records: (state) => state.user.user.record.map((item) => {
        // eslint-disable-next-line
          item.key = uuidv4();
        return item;
      }),
    }),
  },
};
</script>

<style>
</style>
